// 产品序列号管理
import request from '@/router/axios';

// 产品序列号管理
export const getList = (current, size, params) => {
  return request({
    url: `/api/mes-product/product/get-info?current=${current}&size=${size}&isLastest=true`,
    method: 'post',
    data: params
  });
};

// 产品序列号详情
export const getSnDetail = (productId) => {
  return request({
    url: '/api/mes-product/productchange/get-by-productId',
    method: 'get',
    params: {
      productId
    }
  });
};

// 产品跳转工序记录
export const getPassStationRecords = (params) => {
  return request({
    url: '/api/mes-product/process/workorder/skip-route',
    method: 'get',
    params
  });
};

// 跳转工序
export const skipRoute = (data) => {
  return request({
    url: '/api/mes-product/product/skip',
    method: 'post',
    data: data
  });
};

//委外产品序列号excel上传
export const importOutsourcingByExcel = (exportUrl, file) => {
  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: exportUrl,
    method: 'post',
    data: file
  });
};

// 委外产品序列号管理
// export const getOutsourcingList = (current, size, params) => {
//   return request({
//     url: '/api/mes-product/product/page',
//     method: 'get',
//     params: {
//       ...params,
//       current,
//       size
//     }
//   });
// };

// 查询外部包装条码
export const getOutPackingList = (current, size, params) => {
  return request({
    url: '/api/mes-warehouse/packing/query/page/outer/sn',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 查询外部产品序列号
export const getOutList = (current, size, params) => {
  return request({
    url: '/api/mes-product/product/query/page/outer/sn',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 补打标签
export const supplyPrint = (data) => {
  return request({
    url: 'api/mes-product/workorder/generation/supply/print',
    method: 'post',
    data: data
  });
};

export const importData = (url, formData) => {
  return request({
    url: url,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// 查询外部产品序列号
export const getComponentSnsBySn = (params) => {
  return request({
    url: '/api/mes-product/product/list-componentSns-by-sn',
    method: 'get',
    params: {
      ...params
    }
  });
};

// 解绑
export const unbindProductSns = (productId, outSn) => {
  return request({
    url: 'api/mes-product/product/unbind-product-sns?productId=' + productId + '&outSn=' + outSn,
    method: 'post'
  });
};

// 序列号查询分组序列号所有ID
export const getGroupSns = (ids) => {
  return request({
    url: '/api/mes-product/workorder-station/get-group-sns',
    method: 'get',
    params: {
      ids
    }
  });
};

export const getWorkOrderDetail = (workOrderNo) => {
  return request({
    url: '/api/mes-product/work-order/detail',
    method: 'get',
    params: {
      workOrderNo
    }
  });
};

// 更改产品序列号状态
export const changeStatus = (data) => {
  return request({
    url: 'api/mes-product/workorder-station/change-status',
    method: 'post',
    params: data
  });
};

export const reworkInput = (params) => {
  return request({
    url: '/api/mes-product/product/rework-input',
    method: 'post',
    data: params
  });
};

export const getProcess = (workOrderId) => {
  return request({
    url: '/api/mes-product/processwo/detail',
    method: 'get',
    params: {
      workOrderId
    }
  });
};
